// Browser Version OS
var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{
			string: navigator.userAgent,
			subString: "Chrome",
			identity: "Chrome"
		},
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari",
			versionSearch: "Version"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			   string: navigator.userAgent,
			   subString: "iPhone",
			   identity: "iPhone/iPod"
	    },
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};
BrowserDetect.init();

function checkOS() {
	return	BrowserDetect.OS;
}
function checkBROWSER() {
	return	BrowserDetect.browser;
}
function checkVERSION() {
	return	BrowserDetect.version;
}
/* popup start */
var tTimeout;
var tOnclick="";
var tImgStartNo = 0;
var tImgEndNo = 0;
var activeImage = 0;
var tPath = "";
var tImgType = "";
function setParentValues() {
 	tTimeout=parent.tTimeout;
	tOnclick=parent.tOnclick;
	tImgStartNo=parent.tImgStartNo;
	tImgEndNo=parent.tImgEndNo;
	activeImage=parent.activeImage;
	tPath=parent.tPath;
	tImgType=parent.tImgType;
}	
/* vers 1 */
function setActiveImage(imageNo) {
	activeImage = imageNo;
}	
function getActiveImage() {
	if(document.getElementById("gallery")){
		document.getElementById("gallery").src=tPath+activeImage+"."+tImgType;
	}
}
function nextImage() {
	if (activeImage==tImgEndNo) {
		;
	} else if (activeImage==tImgEndNo-1) {
		activeImage=tImgEndNo;
		document.getElementById("nextImg").className="nextOff12";
	} else {
		activeImage++;
		document.getElementById("nextImg").className="nextOn12";
	}
	if (activeImage==tImgStartNo) {
		document.getElementById("prevImg").className="prevOff12";
	} else {
		document.getElementById("prevImg").className="prevOn12";
	} 
	parent.clearTimeout(parent.tTimeout);
	parent.tTimeout = parent.setTimeout('closePortalPopUp()',20000);
	getActiveImage();
}	
function prevImage() {
	if (activeImage==tImgStartNo) {
		;
	} else if (activeImage==tImgStartNo+1) {
		activeImage=tImgStartNo;
		document.getElementById("prevImg").className="prevOff12";
	} else {
		activeImage--;
		document.getElementById("prevImg").className="prevOn12";
	}
	if (activeImage==tImgEndNo) {
		document.getElementById("nextImg").className="nextOff12";
	} else {
		document.getElementById("nextImg").className="nextOn12";
	} 
	parent.clearTimeout(parent.tTimeout);
	parent.tTimeout = parent.setTimeout('closePortalPopUp()',20000);
	getActiveImage();
}	
function openImagePopup(pPath,pImgType,pImgStartNo,pImgEndNo) {
	tOnclick="closePortalPopUp()";
	tImgStartNo = pImgStartNo;
	tImgEndNo = pImgEndNo;
	tPath = pPath;
	tImgType = pImgType
	activeImage = tImgStartNo;
	var picName = new Image();
	picName.src = pPath+pImgStartNo+"."+tImgType;
	var tWidth = GetImagePopupWidth(picName.width);
	var tHeight = GetImagePopupHeight(picName.height);
	
	openPortalPopUp("blabar2popup.html",20000,tHeight,tWidth,"shadow","rootPopUp");
	tOnclick="";
}
/* vers 1 end */
function openPortalPopUp(pPage,pTimeOut,pHeight,pWidth,pCssClass,pRootPopupClass){
	if (document.getElementById("rootPopUp")) {
		document.getElementById("rootPopUp").style.visibility = "visible";
		document.getElementById("rootPopUp").style.display = "";
		document.getElementById("rootPopUp").className = pRootPopupClass;
		document.getElementById("rootPopUpId").src = pPage;
		document.getElementById("rootPopUpId").height = pHeight;
		document.getElementById("rootPopUpId").width = pWidth;
		document.getElementById("topLevel").style.visibility = "visible";
		document.getElementById("topLevel").style.display = "";
		document.getElementById("topLevel").className=pCssClass;
		document.getElementById("topLevel").style.width=document.body.clientWidth;
		document.getElementById("topLevel").style.height=document.body.clientHeight;
		document.getElementById("topLevel").onclick=new Function(tOnclick);
		tTimeout = setTimeout('closePortalPopUp()',pTimeOut);
	}
}
function closePortalPopUp(){
	if (document.getElementById("rootPopUp")) {
		clearTimeout(tTimeout);
		document.getElementById("rootPopUp").style.visibility = "hidden";
		document.getElementById("rootPopUp").className = "rootPopUp";
		document.getElementById("rootPopUp").style.display = "none";
		if (BrowserDetect.browser == "Explorer") {
			document.getElementById("rootPopUpId").contentWindow.document.body.scroll="no";
		} else {
			document.getElementById("rootPopUpId").scrolling = "no";				
		}
		document.getElementById("rootPopUpId").src = "about:blank";
		document.getElementById("topLevel").className="";
		document.getElementById("topLevel").style.visibility = "hidden";
		document.getElementById("topLevel").style.display = "none";
	}
}
function openGallery(pPage,pHeight,pWidth) {
	tOnclick="closePortalPopUp()";
	openPortalPopUp(pPage,20000,pHeight,pWidth,"shadow","galleryPopUp");
	tOnclick="";
}
function GetImagePopupWidth(pWidth) {
	var tWidth = 350;
	if ((pWidth) > tWidth) {
		tWidth = pWidth;
	}
	return tWidth;
}
function GetImagePopupHeight(pHeight) {
	var tHeight = 250;
	if ((pHeight+50) > tHeight) {
		tHeight = pHeight+50;
	}
	return tHeight;
}