var engine = {
	start: function() {
		this.debug();
	//	this.navigation();
		//this.email();
		this.iessie();
		this.images();
		//this.flash();
	},

	/**
	 *@todo usunąć komentarze i zakomentować pierwszą linię ciała metody debug na produkcyjnym
	 */
	debug: function() {
		log = (typeof console == "object") ? console.log : alert;
		//var hash = /#.+$/;
		//var loc = document.location + '';
		//log = function() { return false; }
		//if (loc.match(hash)) {
		//	if (hash.exec(loc)[0] == '#debugjs') {
		//		log = (typeof console == "object") ? console.log : alert;
		//	}
		//}
		dump = function dumper(obj) {
			if(typeof obj == "object") {
				log("Type: " + typeof(obj) + ((obj.constructor) ? "\nConstructor: " + obj.constructor : "") + "\nValue: " + obj + "\n");
			} else {
				log("Type: " + typeof(obj) + "\nValue: " + obj + "\n");
			}
		}
	},
	navigation: function() {
		$('#nav a').click(function() {
			$(this).parent('li').parent('ul').find('li').removeClass('activ');
			$(this).parent('li').addClass('activ');
			 return false;
		});
	},
	images: function() {
		try {
			$(".lightbox, .lightbox-move").lightbox({
				help: ' \u2190 / P - poprzednie zdjęcie\u00a0\u00a0\u00a0\u00a0\u2192 / N - następne zdjęcie\u00a0\u00a0\u00a0\u00a0ESC / X - zamknij galerię',
				prevLinkTitle: 'poprzednie zdjęcie',
				nextLinkTitle: 'następne zdjęcie',
				prevLinkText:  '&laquo; Poprzednia',
				nextLinkText:  'Dalej &raquo;',
				closeTitle: 'zamknij',
				image: 'Zdjęcie ',
				of: ' z '
			});
		} catch(e) {
			//dump(e);
		}
	},
	/*email: function() {
		var domena = 'akademiafotografii.pl';
		$('.email').each(function() {
			var $this = $(this);
			var adres = $this.attr('id');
			$this.attr('href', 'mailto:' + adres + '@' + domena)
			$this.text(adres + '@' + domena)
		});
	},*/
	iessie: function() {
		jQuery.each(jQuery.browser, function(i, val) {
			if(i=="msie" && jQuery.browser.version.substr(0,3)=="6.0") {
				var ln = document.createElement('link');
				ln.href = '/public/layouts/foto/css/base.ie6.css';
				ln.type = 'text/css';ln.rel='stylesheet';
				var he = document.getElementsByTagName('head')[0];
				he.appendChild(ln);
			}
		});
	}
	/*flash: function() {
		try {
			var subclass = '';
			var params = {
				menu: "false",
				wmode: "transparent"
			};
			if (document.getElementById('page-main')) {
				var link = document.getElementById('branch-krakow') ? 'krakow' : 'warszawa';
				subclass = '-main';
				var flashvars = {};
				var attributes = {};
				swfobject.embedSWF("/public/layouts/foto/flash/galeria.swf?link=" + link, "galery-flash", "100%", "100%", "9.0.0","/public/layouts/foto/flash/expressInstall.swf", flashvars, params, attributes);
			}
			$('#nav').after('<div id="partners"></div>')
			var flashvars = {};
			var attributes = {};
			swfobject.embedSWF("/public/layouts/foto/flash/partners" + subclass + ".swf", "partners", "100%", "100%", "9.0.0","/public/layouts/foto/flash/expressInstall.swf", flashvars, params, attributes);

		} catch(e) {
			dump(e);
		}
	}*/
}

$(function() {
	engine.start();
});
