//Global Variables
/* common javsacript file */
// JavaScript Browser Sniffer
// Eric Krok, Andy King, Michel Plungjan Jan. 31, 2002
// see http://www.webreference.com/ for more information
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.

    var agt=navigator.userAgent.toLowerCase();
    var appVer = navigator.appVersion.toLowerCase();
    var is_minor = parseFloat(appVer);
    var is_major = parseInt(is_minor);

	var is_opera = (agt.indexOf("opera") != -1);

	var is_mac = (agt.indexOf("mac")!=-1);
    var iePos  = appVer.indexOf('msie');
    if (iePos !=-1) {
       if(is_mac) {
           var iePos = agt.indexOf('msie');
           is_minor = parseFloat(agt.substring(iePos+5,agt.indexOf(';',iePos)));
       }
       else is_minor = parseFloat(appVer.substring(iePos+5,appVer.indexOf(';',iePos)));
       is_major = parseInt(is_minor);
    }

    var is_konq = false;
    var kqPos   = agt.indexOf('konqueror');
    if (kqPos !=-1) {                 
       is_konq  = true;
       is_minor = parseFloat(agt.substring(kqPos+10,agt.indexOf(';',kqPos)));
       is_major = parseInt(is_minor);
    }                                 

    var is_getElementById   = (document.getElementById) ? "true" : "false";
    var is_getElementsByTagName = (document.getElementsByTagName) ? "true" : "false";
    var is_documentElement = (document.documentElement) ? "true" : "false";

    var is_safari = ((agt.indexOf('safari')!=-1)&&(agt.indexOf('mac')!=-1))?true:false;
    var is_khtml  = (is_safari || is_konq);

    var is_ie   = ((iePos!=-1) && (!is_opera) && (!is_khtml));
	var is_ie4   = (is_ie && is_major == 4);
    var is_ie5   = (is_ie && is_major == 5);
	var is_ie5up = (is_ie && is_minor >= 5);
	var is_ie5_5  = (is_ie && (agt.indexOf("msie 5.5") !=-1)); // 020128 new - abk
	var is_ie6   = (is_ie && is_major == 6);


/* PC-IE4 and Mac IE 5+ redirect */
	if (is_ie4 || (is_ie5up == true && is_mac == true)) {
		window.location="../fail/fail-browser.html";
	}

	var is_ie6below = (is_ie6 || is_ie5_5);

/* function to have multiple events within the onload event */
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}

addLoadEvent( function() {
			 appleSearch('metaSearch');
			 });

/* login / search show / hide */
var aOjb
var bObj

function showMe(whoToShow) {
	document.getElementById(whoToShow).style.display = 'block';
	try {
		aObj = document.getElementById(whoToShow + 'Tab');
		if (is_ie) {
			aObj.setAttribute('className','current');
		} else {
			aObj.setAttribute('class','current');
		}
	} catch (e) {}
}

function hideMe(whoToHide) {
	document.getElementById(whoToHide).style.display = 'none';
	try {
		bObj = document.getElementById(whoToHide + 'Tab');
		if (is_ie) {
			bObj.setAttribute('className','notCurrent');
		} else {
			bObj.setAttribute('class','notCurrent');
		}
	} catch (e) {}
}


/* set random background, includes IE filter for IE6 */
var loadValue = 0;

function determine() {
	loadValue = Math.round(Math.random() * 10 );
	
	try {
		if ((loadValue > 4) || (loadValue < 1)) {
			determine();
		} else {
			document.getElementById('contentFooter').style.background = 'url(../flash/album1/large/hero' + loadValue + '.jpg)';
/*			if (is_ie6below) {
				document.getElementById('contentFooter').style.background = 'none';
				document.getElementById('contentFooter').runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='../flash/album1/large/hero" + loadValue + ".png',sizingMethod='crop')";
			}*/
		}
	} catch (e) {
		alert('An error has occured:' + e);
	}
}
