/************************************************ vi common script *****/
/************************** Copyright (c) 2009 virtual identity AG *****/
/***********************************************************************/
/******************************************************* vi common *****/
/***********************************************************************/
/******************************** Daniel Birke virtual identity AG *****/
/* $LastChangedDate: 2009-09-29 16:56:03 +0200 (Di, 29 Sep 2009) $ *****/

/***********************************************************************/
/* START: configuration */
/* these variables may be overwritten individually inside page header */

var USE_SIFR;
USE_SIFR = USE_SIFR !== undefined ? USE_SIFR : true; // set default

var USE_CSS_BROWSER_FLAG;
USE_CSS_BROWSER_FLAG = USE_CSS_BROWSER_FLAG !== undefined ? USE_CSS_BROWSER_FLAG : true; // set default

// paths
var RESOURCES_PATH;
RESOURCES_PATH = RESOURCES_PATH !== undefined ? RESOURCES_PATH : '/wp-content/themes/virtual_identity/_resources/'; // set default
var MACOS_STYLESHEET_REFERENCE  = RESOURCES_PATH + 'css/styles-macos.css';
var WEBKIT_STYLESHEET_REFERENCE = RESOURCES_PATH + 'css/styles-webkit.css';

var SIFR_PATH;
SIFR_PATH = SIFR_PATH !== undefined ? SIFR_PATH : '/wp-content/themes/virtual_identity/_resources/sifr/'; // set default

/* END: configuration */
/***********************************************************************/
/* START: browser detection                                            */

if(Info !== undefined){
	if (window.console && window.console.log) window.console.log(Info, '[Info] variable collision: Info already defined');
}

var Info = new function() {

	var userAgent = navigator.userAgent.toLowerCase();

	// check user agent
	function is(str) { return userAgent.indexOf(str) > -1; }

	// version detection
	function version() {
		var versionString = '';
		var specificOffset = 0;
		var specificLength = 1;

		if(b.isIE)      { versionString = 'msie'; specificOffset = 1; }
		if(b.isFirefox) { versionString = 'firefox/'; specificLength = 3; }
		if(b.isSafari)  { versionString = 'version/'; } // note: detects only safari 3+
		if(b.isChrome)  { versionString = 'chrome/'; }
		if(b.isOpera)   { versionString = 'version/'; specificLength = 2;
			// for Opera version < 10
			if(userAgent.indexOf(versionString) == -1) {
				versionString = 'opera/'; specificLength = 1;
			}
		}

		return parseFloat((userAgent.substr(userAgent.indexOf(versionString) + versionString.length + specificOffset, specificLength)));
	}

	// browser detection
	var b = {};
	b.isOpera      = typeof window.opera != 'undefined';
	b.isIE         = is('msie') && b.isOpera == false;
	b.isWebkit     = is('webkit');
	b.isChrome     = is('chrome');
	b.isSafari     = is('safari') && (b.isChrome == false) && is('version'); // note: detects only safari 3+
	b.isMozilla    = is('gecko') && b.isWebkit == false && b.isSafari == false && b.isChrome == false && b.isOpera == false;
	b.isFirefox    = b.isMozilla == true && is('firefox');
	b.isKonqueror  = navigator.product != null && navigator.product.toLowerCase().indexOf('konqueror') > -1;
	this.browser   = b;

	//browser version initialization
	b.version = version();
	if(b.version == 0 || isNaN(b.version)) { b.version = false; }

	// backward compatibility, use b.version to detect browser version in new scripts
	b.isSafari3    = b.isSafari && (b.version == 3);
	b.isSafariGte3 = b.isSafari && (b.version >= 3);
	b.isIE7        = b.isIE && (b.version == 7);
	b.isIEpre8     = b.isIE && (b.version < 8);
	b.isIEpre7     = b.isIE && (b.version < 7);
	b.isIEpre6     = b.isIE && (b.version < 6);

	//OS detection
	var os = {};
	os.isLinux     = (navigator.platform.indexOf("Linux") == 0),
	os.isMac       = (navigator.platform.indexOf("Mac") == 0),
	os.isWin       = (navigator.platform.indexOf("Win") == 0)
	this.os        = os;
	
	// windows version detection >> 5.0=2000 5.1=XP, 5.2=2003, 6.0=Vista, 6.1=Win7
	if(this.os.isWin) {
		this.os.winVersion = parseFloat(userAgent.substr(userAgent.indexOf('nt') + 3, 3));
	}
	
	//has transparency support detection
	this.hasTransparencySupport = true;
	if(this.os.isLinux || this.browser.isKonqueror || (this.os.isMac && !(this.browser.isSafari && b.version >= 3))) {
		this.hasTransparencySupport = false;
	}

	//CSS classes
	function setCss() {
		var h = document.getElementsByTagName('html')[0],
		classes=[
			(
				b.isIE      ? ('ie ie' + b.version) :
				b.isFirefox ? ('firefox firefox' + (b.version.toString().replace(/\./ig, ''))) :
				b.isChrome  ? ('chrome chrome' + b.version) :
				b.isSafari  ? ('safari safari' + b.version) :
				b.isOpera   ? ('opera opera' + b.version)	: ''
			),
			(
				b.isMozilla ? 'gecko' :
				b.isWebkit  ? 'webkit' : ''
			),
			(
				os.isWin    ? 'win' :
				os.isMac    ? 'mac' :
				os.isLinux  ? 'linux' : ''
			),
			'js'
		];
		h.className += h.className == '' ? classes.join(' ') : ' ' + classes.join(' ');
		return classes;
	}

	if(USE_CSS_BROWSER_FLAG) setCss();
}

/* END: browser detection                                              */
/***********************************************************************/
/* START: Fix Flickering Background Images                             */

if (window.createPopup && document.compatMode && document.compatMode=='CSS1Compat' && !window.XMLHttpRequest) {
	try{
		document.execCommand('BackgroundImageCache', false, true);
	} catch(e) {}
}

/* END: Fix Flickering Background Images                               */
/***********************************************************************/
/* START: browser dependent configuration */

if (Info.browser.isOpera || Info.os.isLinux) USE_SIFR = false;

// serve special styles for Mac OS and Webkit browsers
if (Info.os.isMac)         document.write('<link rel="stylesheet" media="screen,projection" type="text/css" href="' + MACOS_STYLESHEET_REFERENCE + '" />');
if (Info.browser.isWebkit) document.write('<link rel="stylesheet" media="screen,projection" type="text/css" href="' + WEBKIT_STYLESHEET_REFERENCE + '" />');

/* END: browser dependent configuration */
/***********************************************************************/
/* START: jQuery Lightbox plugin
 * 
 * Source: http://leandrovieira.com/projects/jquery/lightbox/
 * 
 */

$(document).ready(function() {
	$('a.lightbox').lightBox(		// Select all links with lightbox class
		{
			imageLoading:			'/wp-content/themes/virtual_identity/_resources/img/jquery.lightbox-0.5/lightbox-ico-loading.gif',	// (string) Path and the name of the loading icon
			imageBtnPrev:			'/wp-content/themes/virtual_identity/_resources/img/jquery.lightbox-0.5/lightbox-btn-prev.gif',		// (string) Path and the name of the prev button image
			imageBtnNext:			'/wp-content/themes/virtual_identity/_resources/img/jquery.lightbox-0.5/lightbox-btn-next.gif',		// (string) Path and the name of the next button image
			imageBtnClose:			'/wp-content/themes/virtual_identity/_resources/img/jquery.lightbox-0.5/lightbox-btn-close.gif',	// (string) Path and the name of the close btn
			imageBlank:				'/wp-content/themes/virtual_identity/_resources/img/blank.gif',										// (string) Path and the name of a blank image (one pixel)

			containerResizeSpeed: 350,
			txtImage: 'Imagem',
			txtOf: 'de'
		}
	); 
});

/* END: jQuery Lightbox plugin */
/***********************************************************************/