var bAgent = navigator.userAgent;
var bName = navigator.appName;
var bPlugins = navigator.plugins;
var d = document;

function sniffer(){

this.Win = bAgent.indexOf("Win",0) != -1 ? 1 :0;
this.Mac = bAgent.indexOf("Mac",0) != -1 ? 1 :0;
this.MacOSX = ((bAgent.indexOf("Mozilla") != -1) && (bAgent.indexOf("Mac OS X") != -1)) ? 1 :0;
if(bPlugins){for(i=0;i<bPlugins.length;i++){if(this.Mac && (bPlugins[i].filename.indexOf("QuickTime Plugin.plugin")!=-1)){this.MacOSX=true;}}}

this.IE = ((bAgent.indexOf("MSIE") != -1) && (bAgent.indexOf("Opera") == -1)) ? 1 :0;
//this.NS = ((bName == "Netscape") && (bAgent.indexOf("Opera") == -1)) ? 1 :0;
this.NC = ((bName == "Netscape") && (bAgent.indexOf("Gecko") == -1) && (bAgent.indexOf("Opera") == -1)) ? 1 :0;
this.Gecko = (bAgent.indexOf("Gecko") != -1) ? 1 :0;
this.Moz = ((bAgent.indexOf("Gecko") != -1) && (bAgent.indexOf("Safari",0) == -1)) ? 1 :0;
this.OPERA = bAgent.indexOf("Opera",0) != -1 ? 1 :0;
this.SAFARI = bAgent.indexOf("Safari",0) != -1 ? 1 :0;
this.ICAB = bAgent.indexOf("iCab",0) != -1 ? 1 :0;

this.IE3 = (bAgent.indexOf('MSIE 3.',0) != -1);
this.MacIE4 = (this.Mac && (bAgent.indexOf('MSIE 4.',0) != -1));
this.MacIE45 = (this.Mac && (bAgent.indexOf('MSIE 4.5',0) != -1));
this.MacIE5 = (this.Mac && (bAgent.indexOf('MSIE 5.',0) != -1));
this.NS60 = (bAgent.indexOf("Netscape6/6.0") != -1);
this.NS6 = (bAgent.indexOf("Netscape6/") != -1);
this.NS7 = (bAgent.indexOf("Netscape/7") != -1);

/*NS4 = 1, IE4 = 2, IE5+,OPERA5,7 = 3, NS6+,SAFARI,OPERA6 = 4, others = 0*/
this.checkObj = d.all?(d.getElementById?3:2):(d.getElementById?4:(d.layers?1:0));
this.allObj = ((this.checkObj == 1) || (this.checkObj == 2) || (this.checkObj == 3) || (this.checkObj == 4));
this.checkObj4 = (d.getElementById && !d.all) ? 1 :0;
this.checkObj3 = (d.getElementById && d.all) ? 1 :0;
this.checkObj2 = (d.all && !d.getElementById) ? 1 :0;
this.checkObj1 = d.layers ? 1 :0;

this.modeStandard = d.compatMode == "CSS1Compat" ? 1 : 0;
this.modeQuirks = d.compatMode == "BackCompat" ? 1 : 0;

this.WinIE6s = (this.Win && this.IE && this.modeStandard && ((bAgent.indexOf('MSIE 6.',0) != -1)||(bAgent.indexOf('MSIE 7.',0) != -1)));
this.WinIE6q = (this.Win && this.IE &&this. modeQuirks && ((bAgent.indexOf('MSIE 6.',0) != -1)||(bAgent.indexOf('MSIE 7.',0) != -1)));

return this;
}
var usr = new sniffer;


var cssType = (usr.Win && usr.OPERA)?"wie":(usr.MacOSX)?"mie":(usr.Mac && usr.OPERA)?"mie":(usr.Win && usr.IE)?"wie":(usr.Mac && usr.IE)?"mie":(usr.Win && usr.NC)?"wnc":(usr.Win && usr.NS)?"wns":(usr.Mac && usr.NC)?"mnc":(usr.Mac && usr.NS)?"mns":"wie";
function setCss(){
d.open();
if(!!cssType && !usr.IE3 && usr.allObj){
d.write('<link rel=\"stylesheet\" href=\"/shared/css/barbet_' +cssType+ '.css\" type=\"text/css\">');
}else{
d.write('<link rel=\"stylesheet\" href=\"/shared/css/barbet_wie.css\" type=\"text/css\">');
}
d.close();
}
var setupCss = new setCss;

if(! window.definedWidth){
window.onresize = checkSize;
window.definedWidth = window.innerWidth;
window.definedHeight = window.innerHeight;
}
function checkSize(){
if(definedWidth < window.innerWidth || definedWidth > window.innerWidth || definedHeight > window.innerHeight || definedHeight < window.innerHeight){
location.reload();
}
}

/*between 4.51 and 4.61 of NS be no good for meta content type*/
var fileUrl = location.href;
var checkAnchor = fileUrl.indexOf("#",0);
var checkPageScroller = fileUrl.match("pSc");
function resetPage(){
if(!!checkPageScroller){
anchorId = fileUrl.substring(fileUrl.lastIndexOf("?pSc")+4,fileUrl.length);
timerID=setTimeout("toAnchor(anchorId)",400);
}else return true;
}

if(d.images) {
dotblank = new Image();
dotblank.src = "/shared/img/bdy/dot/dot_blank.gif";
}

function changeImgNN(nam,num) {
if(d.images) {
d[nam].src = totop[num].src;
}
}

function changeImgNN2(nam,num) {
if(d.images) {
d[nam].src = chart01[num].src;
}
}

function changeImgNN3(nam,num) {
if(d.images) {
d[nam].src = chart02[num].src;
}
}

var imgIdG1 = imgIdL1 = imgIdP1 = "";
var hldIdG1 = hldIdL1 = hldIdP1 = "";
function changeImg(imgName,imgState,idName) {
if(!window[imgName + imgState]){
return false;
}
if(!idName){
if(d.images) {
var stringId0 = imgName.substring(0,4);
var stringIdG1 = imgName.substring(3,6);
var stringIdL1 = imgName.substring(3,8);
if(((imgState == "out") || (imgState == "ovr")) && (stringId0 == "navl") && (stringIdL1 == imgIdP1)){
if(imgState == "out"){
d[imgName].src = eval(imgName + "opt" + ".src");
}else if(imgState == "ovr"){
d[imgName].src = eval(imgName + "opv" + ".src");
}
} else if(((imgState == "out") || (imgState == "ovr")) && ((stringId0 == "navg") || (stringId0 == "navl")) && ((stringIdG1 == imgIdG1) || (stringIdL1 == imgIdL1))){
if(imgState == "out"){
d[imgName].src = eval(imgName + "hld" + ".src");
}else if(imgState == "ovr"){
d[imgName].src = eval(imgName + "hlv" + ".src");
}
} else {
d[imgName].src = eval(imgName + imgState + ".src");
}
}
}else if(!!idName){
if(usr.checkObj == 2 || usr.checkObj == 3 || usr.checkObj == 4){
d[imgName].src = eval(imgName + imgState + ".src");
}else if(usr.checkObj == 1){
d.layers[idName].d[imgName].src = eval(imgName + imgState + ".src");
}
}
}

function hldNavG1(hldIdG1){
if(hldIdG1 == "00"){
return true;
} else if(!!hldIdG1){
changeImg("navg" + hldIdG1,"hld");
imgIdG1 = ("g" + hldIdG1);
} else {
return true;
}
}

function hldNavL1(hldIdL1){
if(hldIdL1 == "0000"){
return true;
} else if(!!hldIdL1){
parentIdL1 = hldIdL1.substring(2,4);
parentIdL2 = hldIdL1.substring(0,2);
hldIdP1 = (parentIdL2 + "00");
if(parentIdL1 == "00"){
changeImg("navl" + hldIdL1,"hld");
imgIdL1 = ("l" + hldIdL1);
} else {
changeImg("navl" + hldIdL1,"hld");
changeImg("navl" + parentIdL2 + "00","opt");
imgIdL1 = ("l" + hldIdL1);
imgIdP1 = ("l" + hldIdP1);
}
} else {
return true;
}
}

function setVisibleFcs(target){
if(!!(usr.allObj && usr.Win && usr.IE)){
target.style.backgroundColor='#fef4da';
target.style.color='#4f4f4f';
}
}

function setVisibleBlr(target){
if(!!(usr.allObj && usr.Win && usr.IE)){
target.style.backgroundColor='#ffffff';
target.style.color='#4f4f4f';
}
}

function presenceWindow(winName){
if(!!winName)
if(usr.win && (usr.IE4 || usr.Gecko))
return winName.closed;
else return typeof winName.document != "object";
else return true;
}

function pSc(pScURL,winName,subWidth,subHeight){
if(!winName)winName = "sbMain";
if(window.name == "sbMain"){
subWin(pScURL,winName,subWidth,subHeight,subBar,subLoca,subMenu)
}else{
if(!presenceWindow(window.opener)){
window.open(pScURL,winName);
}else{
window[winName] = window.open(pScURL,winName,"location=yes,menubar=yes,personalbar=yes,directories=yes,scrollbars=yes,status=yes,toolbar=yes,copyhistory=yes,resizable=yes");
window.name = "sbSub1";
}
}
}

var ratedWidth = ratedHeight = "";
function subWin(subUrl,subName,subWidth,subHeight,subBar,subLoca,subMenu) {
window.parent.name = "sbMain";
if(usr.allObj){
subWidth += 0;subHeight += 0;
if(usr.Mac && usr.IE){
subWidth -= 16;subHeight += 0;
}
ratedWidth = subWidth;
ratedHeight = subHeight;
var screenX = GetScreenRealSize("width");
var screenY = GetScreenRealSize("height");
var realSizeWidth = GetWindowRealSize("width");
var realSizeHeight = GetWindowRealSize("height");
if(!!screenX && !!realSizeWidth && subWidth > screenX)ratedWidth = realSizeWidth;
if(!!screenY && !!realSizeHeight && subHeight > screenY)ratedHeight = realSizeHeight;
if(!subBar)subBar = "yes";
if(!subLoca)subLoca = "yes";
if(!subMenu)subMenu = "yes";
if(!subName)subName = "Sub";
windowSub = ("window" + subName);
window[windowSub] = window.open(subUrl,subName,"width="+ratedWidth+",height="+ratedHeight+",location="+subLoca+",menubar="+subMenu+",personalbar=no,directories=no,scrollbars="+subBar+",status=yes,toolbar=no,copyhistory=no,resizable=yes,top=0,left=0");
if(!usr.IE3)window[windowSub].focus();
if(!d.all)window[windowSub].moveTo(0,0);
window[windowSub].opener = self;
}
}

function init(){
resetPage();
}
