/**
 * @method getStyleProperty
 * @param {String} propName style property to test
 * @param {HTMLElement} element optional optional element to test
 * @return {String | undefined}
 *
 * @example getStyleProperty('borderRadius');
 */
// http://thinkweb2.com/projects/prototype/feature-testing-css-properties/
var getStyleProperty = (function(){

  var prefixes = ['Moz', 'Webkit', 'Khtml', 'O', 'Ms'];

  function getStyleProperty(propName, element) {
    element = element || document.documentElement;
    var style = element.style,
        prefixed;

    // test standard property first
    if (typeof style[propName] == 'string') return propName;

    // capitalize
    propName = propName.charAt(0).toUpperCase() + propName.slice(1);

    // test vendor specific properties
    for (var i=0, l=prefixes.length; i<l; i++) {
      prefixed = prefixes[i] + propName;
      if (typeof style[prefixed] == 'string') return prefixed;
    }
  }

  return getStyleProperty;
})();


/*
 * jQuery Tooltip plugin 1.3
 *
 * http://bassistance.de/jquery-plugins/jquery-plugin-tooltip/
 * http://docs.jquery.com/Plugins/Tooltip
 *
 * Copyright (c) 2006 - 2008 Jörn Zaefferer
 *
 * $Id: jquery.tooltip.js 5741 2008-06-21 15:22:16Z joern.zaefferer $
 * 
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 */
;(function($){var helper={},current,title,tID,IE=$.browser.msie&&/MSIE\s(5\.5|6\.)/.test(navigator.userAgent),track=false;$.tooltip={blocked:false,defaults:{delay:200,fade:false,showURL:true,extraClass:"",top:15,left:15,id:"tooltip"},block:function(){$.tooltip.blocked=!$.tooltip.blocked;}};$.fn.extend({tooltip:function(settings){settings=$.extend({},$.tooltip.defaults,settings);createHelper(settings);return this.each(function(){$.data(this,"tooltip",settings);this.tOpacity=helper.parent.css("opacity");this.tooltipText=this.title;$(this).removeAttr("title");this.alt="";}).mouseover(save).mouseout(hide).click(hide);},hideWhenEmpty:function(){return this.each(function(){$(this)[$(this).html()?"show":"hide"]();});},url:function(){return this.attr('href')||this.attr('src');}});function createHelper(settings){if(helper.parent)return;helper.parent=$('<div id="'+settings.id+'"><h3></h3><div class="body"></div><div class="url"></div></div>').appendTo(document.body).hide();if($.fn.bgiframe)helper.parent.bgiframe();helper.title=$('h3',helper.parent);helper.body=$('div.body',helper.parent);helper.url=$('div.url',helper.parent);}function settings(element){return $.data(element,"tooltip");}function handle(event){if(settings(this).delay)tID=setTimeout(show,settings(this).delay);else
show();track=!!settings(this).track;$(document.body).bind('mousemove',update);update(event);}function save(){if($.tooltip.blocked||this==current||(!this.tooltipText&&!settings(this).bodyHandler))return;current=this;title=this.tooltipText;if(settings(this).bodyHandler){helper.title.hide();var bodyContent=settings(this).bodyHandler.call(this);if(bodyContent.nodeType||bodyContent.jquery){helper.body.empty().append(bodyContent)}else{helper.body.html(bodyContent);}helper.body.show();}else if(settings(this).showBody){var parts=title.split(settings(this).showBody);helper.title.html(parts.shift()).show();helper.body.empty();for(var i=0,part;(part=parts[i]);i++){if(i>0)helper.body.append("<br/>");helper.body.append(part);}helper.body.hideWhenEmpty();}else{helper.title.html(title).show();helper.body.hide();}if(settings(this).showURL&&$(this).url())helper.url.html($(this).url().replace('http://','')).show();else
helper.url.hide();helper.parent.addClass(settings(this).extraClass);handle.apply(this,arguments);}function show(){tID=null;if((!IE||!$.fn.bgiframe)&&settings(current).fade){if(helper.parent.is(":animated"))helper.parent.stop().show().fadeTo(settings(current).fade,current.tOpacity);else
helper.parent.is(':visible')?helper.parent.fadeTo(settings(current).fade,current.tOpacity):helper.parent.fadeIn(settings(current).fade);}else{helper.parent.show();}update();}function update(event){if($.tooltip.blocked)return;if(event&&event.target.tagName=="OPTION"){return;}if(!track&&helper.parent.is(":visible")){$(document.body).unbind('mousemove',update)}if(current==null){$(document.body).unbind('mousemove',update);return;}helper.parent.removeClass("viewport-right").removeClass("viewport-bottom");var left=helper.parent[0].offsetLeft;var top=helper.parent[0].offsetTop;if(event){left=event.pageX+settings(current).left;top=event.pageY+settings(current).top;var right='auto';if(settings(current).positionLeft){right=$(window).width()-left;left='auto';}helper.parent.css({left:left,right:right,top:top});}var v=viewport(),h=helper.parent[0];if(v.x+v.cx<h.offsetLeft+h.offsetWidth){left-=h.offsetWidth+20+settings(current).left;helper.parent.css({left:left+'px'}).addClass("viewport-right");}if(v.y+v.cy<h.offsetTop+h.offsetHeight){top-=h.offsetHeight+20+settings(current).top;helper.parent.css({top:top+'px'}).addClass("viewport-bottom");}}function viewport(){return{x:$(window).scrollLeft(),y:$(window).scrollTop(),cx:$(window).width(),cy:$(window).height()};}function hide(event){if($.tooltip.blocked)return;if(tID)clearTimeout(tID);current=null;var tsettings=settings(this);function complete(){helper.parent.removeClass(tsettings.extraClass).hide();}if((!IE||!$.fn.bgiframe)&&tsettings.fade){if(helper.parent.is(':animated'))helper.parent.stop().fadeTo(tsettings.fade,0,complete);else
helper.parent.stop().fadeOut(tsettings.fade,complete);}else
complete();}})(jQuery);



/**
 * jQuery.ScrollTo - Easy element scrolling using jQuery.
 * Copyright (c) 2007-2009 Ariel Flesler - aflesler(at)gmail(dot)com | http://flesler.blogspot.com
 * Dual licensed under MIT and GPL.
 * Date: 3/9/2009
 * @author Ariel Flesler
 * @version 1.4.1
 *
 * http://flesler.blogspot.com/2007/10/jqueryscrollto.html
 */
;(function($){var m=$.scrollTo=function(b,h,f){$(window).scrollTo(b,h,f)};m.defaults={axis:'xy',duration:parseFloat($.fn.jquery)>=1.3?0:1};m.window=function(b){return $(window).scrollable()};$.fn.scrollable=function(){return this.map(function(){var b=this,h=!b.nodeName||$.inArray(b.nodeName.toLowerCase(),['iframe','#document','html','body'])!=-1;if(!h)return b;var f=(b.contentWindow||b).document||b.ownerDocument||b;return $.browser.safari||f.compatMode=='BackCompat'?f.body:f.documentElement})};$.fn.scrollTo=function(l,j,a){if(typeof j=='object'){a=j;j=0}if(typeof a=='function')a={onAfter:a};if(l=='max')l=9e9;a=$.extend({},m.defaults,a);j=j||a.speed||a.duration;a.queue=a.queue&&a.axis.length>1;if(a.queue)j/=2;a.offset=n(a.offset);a.over=n(a.over);return this.scrollable().each(function(){var k=this,o=$(k),d=l,p,g={},q=o.is('html,body');switch(typeof d){case'number':case'string':if(/^([+-]=)?\d+(\.\d+)?(px)?$/.test(d)){d=n(d);break}d=$(d,this);case'object':if(d.is||d.style)p=(d=$(d)).offset()}$.each(a.axis.split(''),function(b,h){var f=h=='x'?'Left':'Top',i=f.toLowerCase(),c='scroll'+f,r=k[c],s=h=='x'?'Width':'Height';if(p){g[c]=p[i]+(q?0:r-o.offset()[i]);if(a.margin){g[c]-=parseInt(d.css('margin'+f))||0;g[c]-=parseInt(d.css('border'+f+'Width'))||0}g[c]+=a.offset[i]||0;if(a.over[i])g[c]+=d[s.toLowerCase()]()*a.over[i]}else g[c]=d[i];if(/^\d+$/.test(g[c]))g[c]=g[c]<=0?0:Math.min(g[c],u(s));if(!b&&a.queue){if(r!=g[c])t(a.onAfterFirst);delete g[c]}});t(a.onAfter);function t(b){o.animate(g,j,a.easing,b&&function(){b.call(this,l,a)})};function u(b){var h='scroll'+b;if(!q)return k[h];var f='client'+b,i=k.ownerDocument.documentElement,c=k.ownerDocument.body;return Math.max(i[h],c[h])-Math.min(i[f],c[f])}}).end()};function n(b){return typeof b=='object'?b:{top:b,left:b}}})(jQuery);


// jQuery fadeIn/fadeOut/fadeTo IE cleartype glitch
// http://blog.bmn.name/2008/03/jquery-fadeinfadeout-ie-cleartype-glitch/
$.fn.customFadeIn = function(speed, callback) {
	$(this).fadeIn(speed, function() {
		if (jQuery.browser.msie) {
			$(this).get(0).style.removeAttribute("filter");
		}

		if (callback != undefined)
			callback();
	});
};

$.fn.customFadeOut = function(speed, callback) {
	$(this).fadeOut(speed, function() {
		if (jQuery.browser.msie)
			$(this).get(0).style.removeAttribute("filter");

		if (callback != undefined)
			callback();
	});
};

$.fn.customFadeTo = function(speed, to, callback) {
	$(this).animate({opacity: to}, speed, function() {
		if (to == 1 && jQuery.browser.msie)
			$(this).get(0).style.removeAttribute("filter");

		if (callback != undefined)
			callback();
	});
};


Cufon.replace("h2", { fontFamily: "Titillium"});
Cufon.replace("h3", { fontFamily: "Titillium"});
Cufon.replace("h4", { fontFamily: "Titillium", hover: true});
Cufon.replace("h5", { fontFamily: "Aller"});
Cufon.replace("div#clickstream ul li a", { fontFamily: "Titillium"});
//Cufon.replace("p.intro", { fontFamily: "Aller"});
//Cufon.replace("div#navigation ul li a", { fontFamily: "Aller", hover: true});


$(document).ready(function() {
	var resultMsg = "";

	if ($.browser.opera) {
		$.support.opacity = true;
	}

	if (typeof getStyleProperty("boxShadow") != "string") {
		$("a.thumb").addClass("shadow").prepend("<div class=\"shadow\"></div>");
	}

	$("#navigation").dropSlideMenu({
		indicators: true,
		openEasing: "easeOutQuad",
		closeEasing: "easeInQuad",
		duration: 600,
		delay: 2000,
		hideSelects: false
	});

	// tabs
	if ($("#tabs").length) {
		$("#tabs").tabs({ fx: { opacity: "toggle", height: "toggle", duration: 500 } }); //tabs("rotate" , 10000, false);
	}

	// set form field styles on focus and blur
	$("input[type='text'], textarea").focus(function() { // IE doesn't like this on 'select' elements
		$(this).removeClass("idleField").addClass("focusField");
	}).blur(function() {
		$(this).removeClass("focusField").addClass("idleField");
	});

	// button styles on hover
	$("button").hover(function() {
		$(this).css("background-position", "0 bottom");
	}, function() {
		$(this).css("background-position", "0 top");
	});

	// default form field values on focus and blur
	$(".defaultCheck").focus(function() {
		if (this.value == this.defaultValue) {
			this.value = "";
		}
	}).blur(function() {
		if ($.trim(this.value) == "") {
			this.value = (this.defaultValue ? this.defaultValue : "");
		}
	});

	// get viewport height
	window.viewportHeight = window.innerHeight ? window.innerHeight : $(window).height();
	window.scrollBottom = viewportHeight + 80;
	container = $("#contactFormContainer");

	// contact form show
	$("a[href*='/contact'], a[rel~='contact']").click(function() {
		showContact();
		return false;
	});

	window.showContact = function(r) {
		if (!container.hasClass("on")) {
			container.addClass("on");

			$(document).scrollTo(scrollBottom, 500, { onAfter:function() {
				$("#block1, #block2").customFadeOut(700);
				$("#leftContainer").hide("slide", {duration: 500, direction: "up", easing: "easeInQuad"}, function() {
					$("#contactForm").customFadeIn(1500);
					container.show("slide", {duration: 500, direction: "down", easing: "easeOutQuad"}, function() {
						if (r > "") {
							alert(r);
						}
						else $("#cName").focus();

						$("p#contactClose").fadeIn(700);
					});
				});
			} });
		}
		else {
			$(document).scrollTo(scrollBottom, 500);
			$("#cName").focus();
		}
	};

	// contact form hide
	$("a[rel~='contactClose']").click(function() {
		hideContact();
		return false;
	});

	window.hideContact = function() {
		$("p#contactClose").fadeOut(700);
		$("#contactForm").customFadeOut(700);
		container.hide("slide", {duration: 500, direction: "down", easing: "easeInQuad"}, function() {
			$("#block1, #block2").customFadeIn(1500);
			$("#leftContainer").show("slide", {duration: 500, direction: "up", easing: "easeOutQuad"});
			container.removeClass("on");
		});
	};

	// initialize lightbox
	if ($("a[rel^='prettyPhoto']").length) {
		$("a[rel^='prettyPhoto']").prettyPhoto({
			animationSpeed: 500,
			padding: 0,
			opacity: 0.8,
			showTitle: false,
			allowresize: true,
			counter_separator_label: " / "
		});
	}

	// blog
	window.sociableHide = false;

	$("li.shareLink").mouseover(function() {
		if (sociableHide) { $(".sociable").customFadeOut(0); clearTimeout(sociableHide); }
		$(this).children(".sociable").customFadeIn(0);
	});

	$("li.shareLink").mouseleave(function() {
		var socialList = $(this).children(".sociable");
		sociableHide = setTimeout(function() { socialList.customFadeOut(300); }, 1000);
	});

	$("a:first", "li.shareLink").click(function() {
		return false;
	});

	$("a", "li.commentLink, li.subscribeLink, li.editLink").mouseover(function() {
		$(".sociable").customFadeOut(0);
	});

	// comment reply
	$("div.commentBox").hover(function() {
		$(this).addClass("on");
	}, function() {
		$(this).removeClass("on");
	});

	$("#switch").click(function() {
		$.getJSON("/switcher.php?jsoncallback=?", function(data) {
			var url = "/img/global/backgrounds/" + data.name;
			$("#contentContainer").css("background-image", "url('"+url+"')");
		});

		return false;
	});

	// tooltips
	$("a.thumb img, a.size").tooltip({
		fade: false,
		delay: 0,
		track: true,
		showURL: false,
		top: 25
	});
});



/*!
 * http://www.shamasis.net/projects/ga/
 * Refer jquery.ga.debug.js
 * Revision: 13
 */
(function($){$.ga={};$.ga.load=function(uid,callback){jQuery.ajax({type:'GET',url:(document.location.protocol=="https:"?"https://ssl":"http://www")+'.google-analytics.com/ga.js',cache:true,success:function(){if(typeof _gat==undefined){throw"_gat has not been defined";}t=_gat._getTracker(uid);bind();if($.isFunction(callback)){callback(t)}t._trackPageview()},dataType:'script',data:null})};var t;var bind=function(){if(noT()){throw"pageTracker has not been defined";}for(var $1 in t){if($1.charAt(0)!='_')continue;$.ga[$1.substr(1)]=t[$1]}};var noT=function(){return t==undefined}})(jQuery);

$(window).bind("load", function() {
	$.ga.load("UA-9430599-1");
});