/*//////////////////////////*/
/* CELL(square) Javascript. */
/*//////////////////////////*/

/* Browser Detection */
var detect = navigator.userAgent.toLowerCase();
var OS,browser,version,total,thestring;

if (checkIt('konqueror'))
{
	browser = "Konqueror";
	OS = "Linux";
}
else if (checkIt('safari')) browser = "Safari"
else if (checkIt('omniweb')) browser = "OmniWeb"
else if (checkIt('opera')) browser = "Opera"
else if (checkIt('webtv')) browser = "WebTV";
else if (checkIt('icab')) browser = "iCab"
else if (checkIt('msie')) browser = "Internet Explorer"
else if (!checkIt('compatible'))
{
	browser = "Netscape Navigator"
	version = detect.charAt(8);
}
else browser = "An unknown browser";

if (!version) version = detect.charAt(place + thestring.length);

if (!OS)
{
	if (checkIt('linux')) OS = "Linux";
	else if (checkIt('x11')) OS = "Unix";
	else if (checkIt('mac')) OS = "Mac"
	else if (checkIt('win')) OS = "Windows"
	else OS = "an unknown operating system";
}

function checkIt(string)
{
	place = detect.indexOf(string) + 1;
	thestring = string;
	return place;
}


/* Toggle */
$(document).ready(function() {
	 $(".toggle_desc").hide();
    $(".toggle").click(function () {
     jQuery(this).next(".toggle_desc").slideToggle();
	 jQuery(this).find(".arrow").toggleClass("hl");
    });



/* Tabs */
	$("ul.tabs").tabs("div.panes > div", {effect: "fade", fadeInSpeed: "slow"});

/* Tooltip */
	$(".tip").tooltip({ effect: 'slide',position: 'top center', opacity: 0.9});
	$(".tip_btm").tooltip({ effect: 'slide',position: 'bottom center', opacity: 0.9,offset: [20, 0]});
	$(".tip_left").tooltip({ effect: 'fade',position: 'center left', opacity: 0.9,offset: [0, -20]});
	$(".tip_right").tooltip({ effect: 'fade',position: 'center right', opacity: 0.9,offset: [0, 20]});

/* Lightboxes */
			$("a.lightbox").fancybox({
				'overlayShow'	: false,
				'transitionIn'	: 'elastic',
				'transitionOut'	: 'elastic'
			});

	


			$("a.lightbox_titlein").fancybox({
				'titlePosition'	: 'inside',
				'overlayShow'	: false,
				'transitionIn'	: 'elastic',
				'transitionOut'	: 'elastic'
			});

			$("a.lightbox_titleover").fancybox({
				'titlePosition'	: 'over',
				'overlayShow'	: false,
				'transitionIn'	: 'elastic',
				'transitionOut'	: 'elastic'
			});

		

		
			$(".lightbox_anything").fancybox({
				
				'overlayShow'	: false,
				'transitionIn'	: 'elastic',
				'transitionOut'	: 'elastic',
				'padding'		: 0
			});

			
			$(".lightbox_website").fancybox({
				'width'				: '75%',
				'height'			: '75%',
				'autoScale'			: false,
				'overlayShow'	: false,
				'transitionIn'	: 'elastic',
				'transitionOut'	: 'elastic',
				'type'				: 'iframe'
			});


$(".lightbox_youtube").click(function() {
	$.fancybox({
			'overlayShow'	: false,
				'transitionIn'	: 'elastic',
				'transitionOut'	: 'elastic',
			'padding'		: 0,
			'autoScale'		: false,
	
			'title'			: this.title,
			'width'		: 680,
			'height'		: 495,
			'href'			: this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
			'type'			: 'swf',
			'swf'			: {
			   	 'wmode'		: 'transparent',
				'allowfullscreen'	: 'true'
			}
		});

	return false;
});



	$(".lightbox_vimeo").click(function() {
		$.fancybox({
				'overlayShow'	: false,
				'transitionIn'	: 'elastic',
				'transitionOut'	: 'elastic',
			'padding'		: 0,
			'autoScale'		: false,

			'title'			: this.title,
			'width'			: 680,
			'height'		: 495,
			'href'			: this.href.replace(new RegExp("([0-9])","i"),'moogaloop.swf?clip_id=$1'),
			'type'			: 'swf'
		});

		return false;
	});
	
	
	$(".lightbox_dailymotion").click(function() {
		$.fancybox({
				'overlayShow'	: false,
				'transitionIn'	: 'elastic',
				'transitionOut'	: 'elastic',
			'padding'		: 0,
			'autoScale'		: false,
			'title'			: this.title,
			'width'			: 680,
			'height'		: 495,
			'href'			: this.href.replace(new RegExp("video","i"),'swf/video'),
			'type'			: 'swf'
		});

		return false;
	});
	
		
		
		
	$(".lightbox_soundcloud").click(function() {
		$.fancybox({
				'overlayShow'	: false,
				'transitionIn'	: 'elastic',
				'transitionOut'	: 'elastic',
			
			'autoScale'		: false,
			'title'			: this.title,
			'width'			: 500,
			'height'		: 81,
			'href'			: this.href,
			'type'			: 'swf'
		});

		return false;
	});
		});

/* Image Hover */
jQuery(document).ready(function() {

var enable_image_hover = function(image){
	
		if(image.is(".image_hover")){
		
			if (jQuery.browser.msie && parseInt(jQuery.browser.version, 10) < 7) {} else {
				if (jQuery.browser.msie && parseInt(jQuery.browser.version, 10) < 7) {
					image.hover(function(){
						jQuery(".image_overlay",this).css("visibility", "visible");
						
					},function(){
						jQuery(".image_overlay",this).css("visibility", "hidden");
					}).children('img').after('<span class="image_overlay"></span>');
				}else{
					image.hover(function(){
						
						jQuery(".image_overlay",this).animate({
							opacity: '0.6'
							
						},"fast");
					},function(){
						jQuery(".image_overlay",this).animate({
							opacity: '0'
						},"fast");
					}).children('img').after(jQuery('<span class="image_overlay"></span>').css({opacity: '0',visibility:'visible'}));
				}
			}
		}		
	};
	
		
		
		var image = jQuery(".image_box img").closest('.image_box').find(".image_box_shadow");
			enable_image_hover(image);
});


/* Vertical Align Plugin */
(function ($) {

$.fn.vAlign = function() {
	return this.each(function(i){
	var ah = $(this).height();
	var ph = $(this).parent().height();
	var mh = Math.ceil((ph-ah) / 2);
	$(this).css('margin-top', mh);
	});
};
})(jQuery);

/*
 * tweetable 1.6 - jQuery twitter feed generator plugin
 *
 * Copyright (c) 2009 Philip Beel (http://www.theodin.co.uk/)
 * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) 
 * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
 *
 * With modifications from Philipp Robbel (http://www.robbel.com/) and Patrick DW (stackoverflow)
 * for IE compatibility.
 *
 * Revision: $Id: jquery.tweetable.js 2011-01-06 $ 
 *
 */
(function(a){a.fn.tweetable=function(b){var c={limit:5,username:"philipbeel",time:false,replies:false,position:"append"};var b=a.extend(c,b);return this.each(function(e){var d=a(this);var j;var i="";var f=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];var g="http://api.twitter.com/1/statuses/user_timeline.json?screen_name=";var h="&count=";a.getJSON(g+c.username+h+c.limit+"&callback=?",d,function(k){a.each(k,function(m,n){if(m==0){j=a('<ul class="tweetList">')[c.position.toLowerCase()+"To"](d)}if(c.replies===false){if(n.in_reply_to_status_id===null){j.append('<li class="tweet_content_'+m+'"><p class="tweet_link_'+m+'">'+n.text.replace(/#(.*?)(\s|$)/g,'<span class="hash">#$1 </span>').replace(/(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig,'<a href="$&">$&</a> ').replace(/@(.*?)(\s|\(|\)|$)/g,'<a href="http://twitter.com/$1">@$1 </a>$2')+"</p></li>")}}else{j.append('<li class="tweet_content_'+m+'"><p class="tweet_link_'+m+'">'+n.text.replace(/#(.*?)(\s|$)/g,'<span class="hash">#$1 </span>').replace(/(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig,'<a href="$&">$&</a> ').replace(/@(.*?)(\s|\(|\)|$)/g,'<a href="http://twitter.com/$1">@$1 </a>$2')+"</p></li>")}if(c.time==true){for(var l=0;l<=12;l++){if(f[l]==n.created_at.substr(4,3)){i=l+1;if(i<10){i="0"+i}}}a(".tweet_link_"+m).append("<small> "+n.created_at.substr(8,2)+"/"+i+"/"+n.created_at.substr(26,4)+" "+n.created_at.substr(11,8)+"</small>")}})})})}})(jQuery);


/*
 Lavalamp Plugin (Modified)
 */

(function(a){a.fn.lavaLamp=function(b){b=a.extend({fx:"linear",speed:500,click:function(){}},b||{});return this.each(function(){function i(c){e.each(function(){a(this).dequeue()}).animate({width:c.offsetWidth,left:c.offsetLeft},b.speed,b.fx)}function h(a){e.css({left:a.offsetLeft+"px",width:a.offsetWidth+"px"});g=a}var c=a(this),d=function(){},e=a('<li class="back"><div class="left"></div></li>').appendTo(c),f=a(">li",this),g=a("li.current_page_ancestor",this)[0]||a("li.current_page_item",this)[0]||a(f[0]).addClass("current")[0];f.not(".back").not("ul li ul li").hover(function(){i(this)},d);f.not("ul li ul li").hover(d,function(){i(g)});f.not("ul li ul li").click(function(a){h(this);return b.click.apply(this,[a,this])});h(g);})}})(jQuery)







