function scrollSections() {
	$('a.scrollitem').click(function () {
		$('a.scrollitem').removeClass('selected');
		$(this).addClass('selected');
		$('.toggle').css({'display':'none'});
		$('#wrapper').scrollTo($(this).attr('href'), 1200, function(){
			$('.toggle').css({'display':'block'});
		});
		return false;
	});
}  

function resizePanel() {
	// What happens if we resize the window...
	// Get dimensions
	width = $(window).width();
	height = $(window).height();
	mask_width = width * $('.item').length;
	// Resize the content
	$('#wrapper, .item').css({width: width, height: height});
	$('#mask').css({width: mask_width, height: height});
	// Keep the current section visible (and don't jump back)
	$('#wrapper').scrollTo($('a.selected').attr('href'), 0);
}  

function toggleContent() {
	// When we click on a toggle button (the '+' and '-')
	$('.toggle_button').click(function () {
		// The content hides or show
		$('.container').toggle(300);
		// The buttons class is updated
		$('.toggle_button').toggleClass("active"); 
		return false;
	})
} 

function dropdownMenu() {
	// Hiding all drop downs
	$('#menu .dropdown ul').hide();
	// When hovering the menu
	$('#menu .dropdown').hover(function() {
		// Fading the drop down
		$(this).children('ul').stop().fadeTo(400, 1);
		}, function () { 
		// And hide once the mouse is out
		$(this).children('ul').hide();
	});
} 

function filterableGallery() {
	$('.selecter').mobilyselect({
		collection: 'all',
		animation: 'absolute',
		duration: 500,
		listClass: 'selecterContent',
		btnsClass: 'selecterBtns',
		btnActiveClass: 'active',
		elements: 'li',
		onChange: function(){},
		onComplete: function(){}
	});
}  

function twitterFeed() {
	$(".tweet").tweet({
		username: "keliahdesign", // Enter your username
		join_text: "auto", // If you want texts, see below
		avatar_size: 38, // In pixels
		count: 2, // How many tweets
		auto_join_text_default: "",
		auto_join_text_ed: "",
		auto_join_text_ing: "",
		auto_join_text_reply: "",
		auto_join_text_url: "",
		loading_text: "Loading tweets..."
	});
}  

function flickrFeed() {
	$('#flickrfeed').jflickrfeed({
		limit: 6, // Number of pictures to display
		qstrings: {
			id: '99771506@N00' // Your ID comes here
		},
		// Each image is wrapped with the Colorbox plugin and open the lightbox on click
		itemTemplate: '<div>'+
						'<a rel="flickr" href="{{image}}" title="{{title}}">' +
							'<img src="{{image_s}}" alt="{{title}}" />' +
						'</a>' +
					  '</div>'
	}, function(data) {
		$('#flickrfeed a').colorbox();
	}); 
}  

function colorBox() {
	// For the Colorbox effects and usage, see the portfolio, gallery and typography sections
	// Single Images (with the rel='nofollow')
	$("a[rel='single']").colorbox({rel:'nofollow'});
	// Elastic Effect (use rel='elastic')
	$("a[rel='elastic']").colorbox();
	// Grouping Flickr stream Images with the fade effect (use rel='flickr')
	$("a[rel='flickr']").colorbox({transition:"fade"});
	// Fade Effect (use rel='fade')
	$("a[rel='fade']").colorbox({transition:"fade"});
	// Slideshow Effect (use rel='slideshow')
	$("a[rel='slideshow']").colorbox({slideshow:true});
}  


$(document).ready(function () {

	// Easing style
	jQuery.easing.def = "easeInOutQuart";
	// Hiding the scrollbars (so they are visible if JS is disabled
	$('.container').css({'overflow': 'hidden'});
	// Calling Functions
	toggleContent();
	dropdownMenu();
	filterableGallery();
	twitterFeed();
	flickrFeed();
	colorBox();
	scrollSections();
	// Resize the containers on window resize
    $(window).resize(function() {
		resizePanel();
    }); 


});


$(document).ready(function(){
	$('#tabs div').hide();
	$('#tabs div:first').show();
	$('#tabs ul li:first').addClass('active');
	
	$('#tabs ul li a').click(function(){
	$('#tabs ul li').removeClass('active');
	$(this).parent().addClass('active');
	var currentTab = $(this).attr('href');
	$('#tabs div').hide();
	$(currentTab).show();
	return false;
	});
});

$(document).ready(function(){
	$('#menu div').hide();
	$('#menu div:first').show();
	$('#menu ul li:first').addClass('active');
	
	$('#menu ul li a').click(function(){
	$('#menu ul li').removeClass('active');
	$(this).parent().addClass('active');
	var currentTab = $(this).attr('href');
	$('#menu div').hide();
	$(currentTab).show();
	return false;
	});
});


$(document).ready(function(){
 $("div.read-me a.button").click(function () {
    $("div.read-me div.box").toggle("fast");
 }); 

 hidden = true;
 $("a.button").click(function () {
	if(hidden == false) {
 		$("div.box").slideUp('fast');
		hidden = true;
	} else {
		$("div.box").slideDown('fast');
		hidden = false;
	}
 });
});



$(document).ready(function(){
 $("div.read-me-dev a.button-dev").click(function () {
    $("div.read-me-dev div.box-dev").toggle("fast");
 }); 

 hidden = true;
 $("a.button-dev").click(function () {
	if(hidden == false) {
 		$("div.box-dev").slideUp('fast');
		hidden = true;
	} else {
		$("div.box-dev").slideDown('fast');
		hidden = false;
	}
 });
});



$(document).ready(function(){
	//Examples of how to assign the ColorBox event to elements
	$("a[rel='example1']").colorbox();
	$("a[rel='example2']").colorbox({transition:"fade"});
	$("a[rel='example3']").colorbox({transition:"none", width:"75%", height:"75%"});
	$("a[rel='example4']").colorbox({slideshow:true});
	$(".example5").colorbox();
	$(".example6").colorbox({width:"100%", height:"100%", iframe:true});
	$(".example7").colorbox({width:"500px", height:"80%", iframe:true});
	$(".example8").colorbox({width:"50%", inline:true, href:"#inline_example1"});
	$(".example9").colorbox({
		onOpen:function(){ alert('onOpen: colorbox is about to open'); },
		onLoad:function(){ alert('onLoad: colorbox has started to load the targeted content'); },
		onComplete:function(){ alert('onComplete: colorbox has displayed the loaded content'); },
		onCleanup:function(){ alert('onCleanup: colorbox has begun the close process'); },
		onClosed:function(){ alert('onClosed: colorbox has completely closed'); }
	});
	
	//Example of preserving a JavaScript event for inline calls.
	$("#click").click(function(){ 
		$('#click').css({"background-color":"#f00", "color":"#fff", "cursor":"inherit"}).text("Open this window again and this message will still be here.");
		return false;
	});
});

// Intro settings
function typwriter(el,text,pos,no){
  ctext=text.substring(0,pos)+(pos%2?'_':'<blink>_</blink>');
  $(el).html(ctext);

if(pos==64){/* This is where you need to sepcify the charicter number */
$(el).html("<h1>Kubik Homes</h1>Construct. Develop. Design.",0,2); /* finished text */
}
else
  if(pos==text.length){
   $(el).html(text+"");
   if(text=="index.html"){ 
   ///$("#intro").load("../index.htm");  
   window.location.href='';}; /* load a URL if you like? */
	
   }
  else
   window.setTimeout('typwriter("'+el+'","'+text+'",'+(pos+1)+','+1+');',100); /* Choose the speed of the typing smaller number for faster */
 }
 typwriter('#slide-client',"<h1>Kubik Homes</h1>Construct. Develop. Design.",0); /* the text as it is typed */


//Tooltip 
this.tooltip = function(){	
		
	xOffset = 50;
	yOffset = -65;		

	$("a.tooltip").hover(function(e){											  
		this.t = this.title;
		this.title = "";									  
		$("body").append("<p id='tooltip'>"+ this.t +"</p>");
		$("#tooltip")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn(250);		
    },
	function(){
		this.title = this.t;		
		$("#tooltip").remove();
    });	
	$("a.tooltip").mousemove(function(e){
		$("#tooltip")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});			
};
$(document).ready(function(){
	tooltip();
});
